import { Controller, Headers, Post } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
import { MenuService } from '../service/menu.service';

/*
 * @Author: moeWang
 * @Date: 2022-03-08 14:17:49
 * @LastEditTime: 2022-03-08 17:49:47
 * @LastEditors: moeWang
 * @Description:
 * @FilePath: \nest-web\src\logical\menu\controller\menu.controller.ts
 */
@ApiSecurity('Authorization')
@ApiTags('菜单相关接口')
@Controller('/api/menu')
export class MenuController {
  constructor(
    private readonly menuService: MenuService,
    private readonly jwtService: JwtService,
  ) {}
  
  @ApiOperation({ summary: '获取菜单列表' })
  @Post('get')
  async get(@Headers('authorization') token) {
    const tokenInfo = this.jwtService.decode(token);
    return this.menuService.get(tokenInfo);
  }
}
